package drg_group.wuhan_2022.MDC;

import java.util.HashMap;
import java.util.Map;
import java.util.Set;
import java.util.stream.Collectors;

import drg_group.wuhan_2022.Base;
import drg_group.wuhan_2022.MedicalRecord;
import drg_group.wuhan_2022.ADRG.*;

public class MDCN{
    public static String group(MedicalRecord record){
        String[] mdc_zd={"Q50.400","S38.200x002","Q50.301","N83.600","T83.305","N82.102","A18.112+N74.0*","N84.900","T83.302","D07.304","T83.303","Q52.402","D25.000","Q51.803","N85.000x002","N88.201","D39.706","S30.200x008","D25.100x001","C79.800x209","C57.300x001","N83.800x021","N83.203","C51.200","A60.000x003+N77.1*","N85.500","N83.903","N80.200x001","C79.814","L29.200","N85.200","Q51.001","N76.200","D39.204","C52.x00","Q52.703","A18.115+N74.1*","N82.901","N32.004","N76.101","N71.900x001","N81.201","D07.100x002","D39.702","N73.801","D26.000","S31.400x002","N89.808","N80.301","N80.800x010","N99.300","N83.202","D18.000x853","N89.805","C77.500x003","E28.302","D26.900","Q52.101","C79.800x213","R93.800x006","C46.700x001","S37.601","E28.303","N76.001","N90.301","Q51.900","D39.705","D07.200x002","Z31.000x001","B37.302+N77.1*","N70.900x003","N71.102","N82.101","C79.800x216","R87.400","Z31.300x001","N99.800x007","N92.500","T19.202","C57.800x005","D17.300x003","N85.801","Q51.000","N76.801","S37.610","C57.101","N73.003","D28.100","A18.111+N74.1*","N83.503","N85.300x001","A18.100x032","N89.600x001","N90.404","C79.822","N90.808","D06.900x002","N85.600","N70.903","Q50.200","N84.302","N85.100","N89.503","N85.800x003","N90.001","N92.101","D25.200x002","N83.000","N94.804","N80.601","N88.805","N98.900","N90.501","A42.805","N84.000","N70.904","S31.400x003","N81.202","Q51.300","Q51.202","N81.301","E89.400x002","C54.900","N92.400x004","Z31.200x003","N90.402","D25.200","N80.100x001","D28.206","N70.906","D07.100","C76.307","Q51.501","C57.801","C54.001","N91.400","N85.811","I89.800x032","D28.700x001","N76.401","N83.201","N83.800x017","N92.100x001","N92.400x001","N83.102","N73.203","N89.807","N89.901","D27.x01","D39.709","D26.100x002","N70.900","N83.812","N85.003","N95.900x001","S39.902","N81.500x002","N97.200x002","Q50.600x904","N82.801","I89.800x033","N81.802","N82.501","N81.803","Q51.100","Z31.200","E28.200x003","N73.600","N73.602","N93.901","Q52.403","N83.901","S37.400","N85.002","D07.200","N83.001","N80.401","Q50.602","N89.501","N73.903","Q50.302","N81.300","N90.403","D39.704","D07.301","Z31.201","N81.100","O08.400x005","A54.003","C57.000","Z01.800x003","D25.900x001","A56.004","N87.901","N97.000x001","N72.x01","N88.200x001","Q50.100","A18.113+N74.1*","S38.200x006","N94.000","N75.801","N80.807","N92.400","D39.700x001","N83.101","D07.303","N80.300","C54.800","N75.100","C45.100","C79.800x206","N81.602","N83.000x002","N88.101","D39.005","Q52.406","N88.801","S30.200x007","N76.600","N83.300x001","C57.803","N90.302","N90.401","N89.800x009","N76.201","N83.100x003","R93.803","N94.807","S31.402","C53.900","T83.400","N76.400","N82.401","N85.810","N81.102","A56.003","C57.900","A54.005","N80.001","E28.200","C51.000","N85.809","Q52.400x007","N82.502","N83.700","C57.800x004","N71.902","E28.300x002","Q52.405","N83.811","N99.807","N94.900","S37.600x002","N81.600","N90.700","N83.800x013","T83.301","N89.101","C57.700","N88.000","A54.004","N90.800x012","N95.101","A59.002+N77.1*","N71.101","N72.x02","C79.800x220","N83.207","N73.605","N82.303","N94.300","N90.806","Q50.601","N88.800x010","C79.800x211","N90.803","Q50.000","C57.300","Q51.802","N97.900","A56.100x003+N74.4*","C54.000","N83.802","S37.810","N90.101","N90.600","N89.000","A54.102","C57.702","A51.400x009+N74.2*","R87.800","N90.000","Q50.000x021","N97.800x004","N94.808","N90.901","N85.813","A18.102","N90.902","N89.700","C51.001","C58.x00","N76.500","N83.804","D25.000x002","N83.902","C79.833","N85.402","N70.001","D06.900","N80.803","N70.101","N83.504","Q85.900x047","S38.200x001","N85.600x001","B37.300+N77.1*","N97.300","N82.100x001","S37.410","N80.808","D26.701","N70.901","I77.009","N82.300","Q52.401","N81.801","N90.800x009","N82.302","Q52.000","D39.900x001","N86.x01","N92.000x002","N83.501","A18.100x030+N77.0*","N99.801","N90.811","N83.800x012","N90.807","N82.000","D06.700","D39.002","S37.510","C79.600","B37.300x002+N77.1*","E30.900","N80.805","N83.204","N76.601","N70.900x007","C53.000","N83.810","N81.500","D28.000x002","N99.800x003","Q51.800x011","N99.800x010","N73.501","D48.127","N94.400","N93.000x001","N76.000x001","Q50.504","C79.823","E28.300x001","N73.902","N73.002","N92.400x003","D06.100","N70.104","N89.803","N90.200","N71.002","D25.901","N80.804","N81.601","N80.806","Q52.300","N95.200","C51.800","A18.100x026+N74.1*","N90.810","D07.302","D28.201","D39.707","R87.600","Q52.601","N85.404","N82.902","C79.800x228","N98.000","C57.701","N85.000x004","Q51.400","C79.800x222","D28.202","Q52.700x003","A18.100x019+N77.1*","Q50.502","D18.000x854","N83.500x004","N70.000","A54.201+N74.3*","N85.802","T19.300x001","N83.801","E28.000","N85.700","N70.102","C79.813","N85.400","N88.102","N82.301","D39.200x002","E89.401","N88.100","N94.100","N97.801","D26.100","N84.100","S31.401","D26.702","C56.x00x003","N76.000","N96.x00x003","C53.800","N89.600x002","A56.101+N74.4*","Q50.401","Q52.700x004","N91.100","N85.814","N83.500x007","Q51.806","N87.100","Q27.813","N76.000x006","N80.602","N87.000","Q50.000x011","N72.x03","N98.800","E28.301","N80.000","S39.901","C56.x00","C57.000x002","D39.200x001","N88.806","N82.103","Q50.503","N80.800x011","Z01.400x001","N85.815","Q51.801","S30.207","D39.000x001","A54.200x004+N74.3*","N89.804","N85.300","N85.901","Q50.501","S37.500","N92.300","R87.300","E28.900","N82.201","N81.900","D28.203","T83.400x001","N87.200x001","N89.400","D26.700","D39.004","N80.603","N81.200","N84.300","N71.901","N85.001","N89.601","N82.200","N90.809","D06.000","D39.100x001","Q52.500x001","N94.200","E28.800x002","N89.811","C76.303","N91.200x002","C57.100","N88.900","N97.901","N97.100x003","C57.400","N89.600","N80.501","N85.101","C54.100","N86.x02","C55.x00","N89.802","I89.000x019","N92.600","D39.700x002","C54.200","T83.304","C51.100","A18.100x021+N37.8*","N90.801","Q51.901","Q52.200","N83.809","N90.802","N73.601","N90.800x011","N90.601","N89.810","N85.803","D39.203","Q51.800x012","N80.500","N87.900","Q56.200","N84.001","N88.807","D28.200x003","D39.708","N70.902","N84.800x002","N85.807","N88.400","C53.100","N98.200","N94.806","N73.604","N95.100","N81.101","N84.200","A56.104+N74.4*","D28.205","N85.403","Z52.800x001","N72.x00x006","N83.806","E89.400x001","C79.824","N92.601","E28.300x008","N73.101","N73.102","S37.600","D28.000","S31.400x001","N84.301","N73.103","N83.807","C58.x00x002","C79.812","N73.104","N72.x00x003","N90.300","C79.800x223","N81.000","N81.800x004","N75.802","R87.700","N90.100","D18.000x824","N83.206","D28.900","N99.200","N89.801","N83.205","N94.600","D17.700x024","D39.003","N88.300","Q51.800x007","N83.100x002","Z31.300x002","D07.000","N80.303","E28.100","Q27.816","I86.300","N90.804","N85.804","Q52.400x006","N76.300x001","N97.200x001","D39.101","A18.100x024+N74.1*","N82.900x003","C57.802","N85.806","N73.603","N83.601","D25.900","N70.103","N90.500","A56.100x004+N74.4*","Q50.603","O08.300x004","N76.000x004","N88.804","C79.800x218","N91.000","N85.808","N95.201","D25.100x002","N82.900","M35.202+N77.8*","N81.203","N75.900","N73.202","R93.800x007","N81.500x003","N83.808","N93.801","N85.805","N88.802","Q51.100x001","N82.500","A42.804","N97.101","R87.500","N76.000x003","D18.000x817","N87.101","N83.800x015","I89.000x018","N89.001","N80.200","D39.001","N94.805","N91.500","B37.301+N77.1*","N70.905","N76.100x001","N90.805","N91.200","N75.000","N91.300","T19.201","Q52.103","D39.201","Q51.808","N70.100","N95.800","Q50.300x101","C79.800x219","N90.400","C57.200","Q51.201","Q52.701","Q51.203","S37.710","D28.200x002","N85.812","N89.100","N87.001","N95.000","C79.800x215","N89.502","N94.800x009","N73.500","N73.800x002","C58.x00x003","N83.300x002","B26.800x009+N74.8*","E28.300x005","N83.401","N71.001","S30.200x010","D18.000x856","N73.600x006","N87.002","Q50.303","Q52.700x005","C57.301","Q52.104","N94.803","N92.401","C53.801","D39.901","N80.100","D27.x00","D39.703","N73.606","N85.401","N70.002","N86.x00x004","N99.800x005","N92.000x001","Q27.814","N89.200","Q51.805","Q50.600","Q85.900x045","N83.803","N97.100x001","N73.400","N89.300","N94.500","C79.800x214","Q50.600x903","N83.805","N90.701","Q52.407","N80.302","N96.x00","N93.900","S37.602","D39.000x002","N97.902","R87.100","N94.802","N81.400","N98.100","N83.502","N89.809","Q52.800x004","N89.806","D39.710","Q51.502","Q51.600","D39.202","N96.x00x002","C79.800x205","D28.204","Q52.702","R87.200","Q51.804","A56.002","Q51.000x001","N95.300x001","N76.301","C51.900","D39.100x003","N83.100","D39.701","N73.201","Q52.404","N81.800x005","N83.800x016","Z31.100","N76.100x002","A18.114+N74.1*","C79.800x202","N92.200","N98.300","C54.300","N88.808","N99.201","R87.000","N76.802","N80.600","N85.000","N90.800x010","N73.001","Q52.408","N80.900","N73.300","N85.816"};
        String[] dept_list={};
        if (!(true && Base.contains(mdc_zd,record.zdList[0]) && record.gender!=null && record.gender.equals("2"))){
            return "";
        }
        
        Base.groupMessages.putMessage(record.Index,"符合MDCN入组条件，匹配规则：主诊断匹配、女性");
        String result;

        result=NA1.group(record);
        if (result.length()>0){
            return result;
        }

        result=NA2.group(record);
        if (result.length()>0){
            return result;
        }

        result=NB1.group(record);
        if (result.length()>0){
            return result;
        }

        result=NC1.group(record);
        if (result.length()>0){
            return result;
        }

        result=ND1.group(record);
        if (result.length()>0){
            return result;
        }

        result=NE1.group(record);
        if (result.length()>0){
            return result;
        }

        result=NF1.group(record);
        if (result.length()>0){
            return result;
        }

        result=NG1.group(record);
        if (result.length()>0){
            return result;
        }

        result=NJ1.group(record);
        if (result.length()>0){
            return result;
        }

        if (false && record.ssList!=null && record.ssList.length>0  && Base.intersect(Base.SS_VALID,record.ssList)){
            Base.groupMessages.putMessage(record.Index,"符合NQY入组条件，存在有效手术操作："+String.join(",",Base.Intersect(record.ssList,Base.SS_VALID)));
            return "NQY";
        }

        result=NR1.group(record);
        if (result.length()>0){
            return result;
        }

        result=NS1.group(record);
        if (result.length()>0){
            return result;
        }

        result=NZ1.group(record);
        if (result.length()>0){
            return result;
        }

        Base.groupMessages.putMessage(record.Index,"不符合MDCN的ADRG入组条件");
        return "";
    }
}

